import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CorporateVO, CorporateForm, CorporateQuery } from '@/api/customer/corporate/types';

/**
 * 查询下游客户公司列表
 * @param query
 * @returns {*}
 */

export const listCorporate = (query?: CorporateQuery): AxiosPromise<CorporateVO[]> => {
  return request({
    url: '/customer/corporate/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询下游客户公司列表
 * @param query
 * @returns {*}
 */

export const listCorporateAll = (): AxiosPromise<CorporateVO[]> => {
  return request({
    url: '/customer/corporate/listAll',
    method: 'get'
  });
};


/**
 * 查询下游客户公司详细
 * @param id
 */
export const getCorporate = (id: string | number): AxiosPromise<CorporateVO> => {
  return request({
    url: '/customer/corporate/' + id,
    method: 'get'
  });
};

/**
 * 新增下游客户公司
 * @param data
 */
export const addCorporate = (data: CorporateForm) => {
  return request({
    url: '/customer/corporate',
    method: 'post',
    data: data
  });
};

/**
 * 初始化下游客户公司信息
 * @param data
 */
export const newCorporate = () => {
  return request({
    url: '/customer/corporate/new',
    method: 'get'
  });
};

/**
 * 修改下游客户公司
 * @param data
 */
export const updateCorporate = (data: CorporateForm) => {
  return request({
    url: '/customer/corporate',
    method: 'put',
    data: data
  });
};

/**
 * 删除下游客户公司
 * @param id
 */
export const delCorporate = (id: string | number | Array<string | number>) => {
  return request({
    url: '/customer/corporate/' + id,
    method: 'delete'
  });
};
